#include "messagedialog.h"
#include "ui_messagedialog.h"

MessageDialog * MessageDialog::dialog;

MessageDialog::MessageDialog(QWidget *parent) :
    KeyControllableMenu(parent),
    ui(new Ui::MessageDialog)
{
    ui->setupUi(this);
    okButton=new Button(QIcon(""),"Ok",ui->widget);
    ui->widget->setLayout(new QVBoxLayout());
    ui->widget->layout()->addWidget(okButton);
    addRow(okButton);
    setWindowFlags(Qt::WindowStaysOnTopHint| Qt::Dialog | Qt::FramelessWindowHint);
}

MessageDialog::~MessageDialog()
{
    delete ui;
}

void MessageDialog::buttonSelected() {
    hide();
    parent->grabKeyboard();
}

void MessageDialog::showDialog(QString message, QWidget * parent) {
    if(!dialog) {
        dialog=new MessageDialog(parent);
    }
    dialog->show(message,parent);
}

void MessageDialog::show(QString message, QWidget * parent) {
    ui->message->setText(message);
    KeyControllableMenu::show();
    this->parent=parent;
    grabKeyboard();
}
